<template>
  <el-row type="flex" align="middle" style="height:64px;">
    <el-col :span="4">
      <h1>后台管理系统</h1>
    </el-col>
    <el-col :span="2">
      <i class="el-icon-s-operation" style="color:#fff;font-size:35px"></i>
    </el-col>
    <el-col>
      <span class="day">{{ time }}</span>
    </el-col>
    <el-col :span="1" :offset="6">
      <el-avatar
        :size="50"
        src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
      ></el-avatar>
      <span style="color:beige;height:100%;">将爱意偷藏</span>
    </el-col>
    <el-col :span="2">
      <el-dropdown>
        <span class="el-dropdown-link">
          下拉菜单<i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>修改资料</el-dropdown-item>
          <el-dropdown-item>修改密码</el-dropdown-item>
          <el-dropdown-item>退出登录</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </el-col>
    <el-col :span="2">
      <el-button
        type="primary"
        @click="back"
        style="background:rgb(232, 246, 255);border:0;color:teal;"
        >回首页</el-button
      >
    </el-col>
  </el-row>
</template>

<script>
export default {
  data() {
    return {
      time: "",
    };
  },
  methods: {
    back() {
      window.location.hash = "Home";
    },
    double(value) {
      return String(value).length === 2 ? value : "0" + value;
    },
  },
  mounted() {
    setInterval(() => {
      const date = new Date();
      const Y = date.getFullYear();
      const M = date.getMonth() + 1;
      const R = date.getDate();
      const hour = date.getHours();
      const min = date.getMinutes();
      const sec = date.getSeconds();
      const week = date.getDay();
      let weeks = [
        "星期日",
        "星期一",
        "星期二",
        "星期三",
        "星期四",
        "星期五",
        "星期六",
      ];
      return (this.time = `${Y}-${this.double(M)}-${this.double(
        R
      )} ${this.double(hour)}:${this.double(min)}:${this.double(sec)} ${
        weeks[week]
      }`);
    }, 1000);
  },
};
</script>

<style>
h1 {
  color: beige;
}
.el-dropdown-link {
  color: teal;
  font-size: 16px;
  background: beige;
  padding: 5px;
  border-radius: 8px;
}
.day {
  width: 150px;
  line-height: 24px;
  display: block;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  color: cadetblue;
  background: #fff;
}
</style>
